<?php


namespace App\Http\Controllers\Api;
use App\Http\Controllers\BaseController;
use App\Models\Category;
use Illuminate\Http\Request;

class CategoryController extends BaseController
{
    /**
     * 列表
     * @param Request $request
     * @return mixed
     */
    public function index(Request $request) {
        $type = $request->input('type', Category::TYPE_COOKBOOK);
        $users = Category::with('child')->type($type)->where('parent_id', 0)->orderBy("sort", "desc")->orderBy("id", "desc")
            ->paginate(\request('per_page', 999));
        return $this->paginate($users);
    }
}

